<script src="<?php echo $this->config->item('base_url'); ?>js/echarts/dist/echarts.js"></script>
<script src="<?php echo $this->config->item('base_url'); ?>js/echarts/theme/macarons.js"></script>

<input type="year"/>
<input type="time"/>
<input type="date"/>
    



<div id="visitor-time" style="height:600px;width: 1000px;overflow: hidden;margin:0;"></div>
<script>
    $(function(){
        var time=[];
        time.init=function(){
            this.chart=echarts.init(document.getElementById('visitor-time'), 'macarons');
            this.getTimeChart();
        }
        time.getTimeChart()=function(type){
            $.ajax({
                url: '<?php echo $this->config->item('base_url'); ?>visitor/gettotal?type=' + type + '&month=' + month.id + '&day=' + day.id,
                method: 'post',
                success: function (re) {
                    var obj = $.parseJSON(re);
                    data = obj['data'];
                    option = {
                        color: ['#3398DB'],
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {// 坐标轴指示器，坐标轴触发有效
                                type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                            }
                        },
                        grid: {
                            left: '3%',
                            right: '4%',
                            bottom: '3%',
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: 'category',
                                data: [1,2,3],
                                name: '月份',
                                axisTick: {
                                    alignWithLabel: true
                                }

                            }
                        ],
                        yAxis: [
                            {
                                type: 'value'
                            }
                        ],
                        series: [
                            {
                                name: '访问量',
                                type: 'bar',
                                barWidth: '60%',
                                data: data
                            }
                        ]
                    };
                }
            })
    
        }
        time.changeX=function(){
            this.getTimeChart('day');
        }
        time.init();
    });
    //chart.setOption(option);
</script>
</body>